package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"path/filepath"
)

func printTree(dirPath string, indent string) {
	files, err := ioutil.ReadDir(dirPath)
	if err != nil {
		log.Fatal(err)
	}

	for i, file := range files {
		filename := file.Name()
		if i == len(files)-1 {
			fmt.Printf("%s└── %s\n", indent, filename)
		} else {
			fmt.Printf("%s├── %s\n", indent, filename)
		}

		if file.IsDir() {
			newIndent := indent + "│   "
			printTree(filepath.Join(dirPath, filename), newIndent)
		}
	}
}

func main() {
	dirPath := ""
	fmt.Print("请输入目录路径：")
	fmt.Scan(&dirPath)

	fmt.Printf("%s\n", dirPath)
	printTree(dirPath, "")
}
